package com.xyauto.uilib.colorpicker;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;

import com.xyauto.uilib.R;

/**
 * created by gongziyi on 2024/7/12 14:32
 */
public class DefaultLayerProvider implements IBitmapLayerProvider {

    public final int[] supportLayerIds = new int[2];
    public final int[] skinLayerIds = new int[2];

    public DefaultLayerProvider() {
        supportLayerIds[0] = R.id.bitcolor_layer_0;
        supportLayerIds[1] = R.id.bitcolor_layer_1;
    }

    @Override
    public int getGradientSize() {
        return 2;
    }

    @Override
    public int getLayerSize() {
        return 2;
    }

    @Override
    public int getLayerIndex(int layerId) {
        for (int index = 0; index < supportLayerIds.length; index++) {
            if (layerId == supportLayerIds[index] || layerId == skinLayerIds[index]) {
                return index;
            }
        }
        return -1;
    }

    @Override
    public void loadTargetResLayerId(Context context) {
        for (int i = 0; i < supportLayerIds.length; i++) {
            skinLayerIds[i] = loadTargetResLayerId(context, supportLayerIds[i]);
        }
    }

    public int loadTargetResLayerId(Context context, int supportLayerId) {
        return 0;
    }

    @Override
    public Drawable loadTargetResDrawable(Context context, int res) {
        return ContextCompat.getDrawable(context, res);
    }
}
